from app.web import abstract
import urllib

class Action(abstract.Action):
    
    def get(self):

        wish_id = self.param('wish_id', 'id')
        type = self.param("t")
        
        wish = abstract.models.wish.wishById(wish_id)
        
        wish.title = abstract.utils.xssescape(wish.title)
        
        q = unicode(wish.title).encode("utf-8")
        q = urllib.quote_plus(q)
        
        if type == "e":
            search_url = "http://shop.ebay.de/?_nkw=" + q
        elif type == "g":
            search_url = "http://google.de/products?q=" + q
        else: 
            search_url = "http://www.amazon.de/gp/search?ie=UTF8&keywords=" + q + "&tag=appwind-21&index=blended&linkCode=ur2&camp=1638&creative=6742"

        abstract.logging.info(search_url)
        
        self.redirect(search_url)